<template>
  <div class="ResidualAdmin">
    <a-tabs defaultActiveKey="1" @change="callback">
      <a-tab-pane tab="代理商提现" key="1">
        <a-card>
          <a-form :form="form">
            <a-row :gutter="30">
              <a-col :span="8">
                <a-form-item
                  label="工单时间"
                  :label-col="{ span: 6 }"
                  :wrapper-col="{ span: 16,offset:1 }"
                >
                  <a-range-picker
                    style="width: 100%"
                    v-decorator="[' rangeConfig', rangeConfig]"
                    show-time
                    format="YYYY-MM-DD HH:mm:ss"
                  />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item
                  label="工单号"
                  :label-col="{ span: 6}"
                  :wrapper-col="{ span: 16, offset: 1}"
                >
                  <a-input
                    placeholder="请输入"
                    v-decorator="[
          'workNumber',
          {rules: [{ required: true, message: '请输入工单号!' }]}
        ]"
                  />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item
                  label="代理商名称"
                  :label-col="{ span: 6}"
                  :wrapper-col="{ span: 16, offset: 1}"
                >
                  <a-input
                    placeholder="请输入"
                    v-decorator="[
          'agentName',
          {rules: [{ required: true, message: '请输入代理商名称!' }]}
        ]"
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="30">
              <a-col :span="23" :style="{ textAlign: 'right' }">
                <a-button type="primary" @click="agentSearch()">查询</a-button>
                <a-button type="dashed" @click="agentExport()">导出</a-button>
                <a-button @click="resetSearch()">重置</a-button>
              </a-col>
            </a-row>
          </a-form>
        </a-card>

        <a-card style="margin-top:2%;">
          <a-row :gutter="30">
            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/实际入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">实际入账总额：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >{{ this.sumInAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/微信入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">微信收入：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >{{ this.sumWxAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/支付宝入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">支付宝收入：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >2945.00</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>
          </a-row>

          <a-row :gutter="30" style="margin-top:2%">
            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/代理商收入.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">代理商收入总额：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(16, 144, 255);"
                    >{{ this.sumAgentAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/总部分润.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">总部分润总额：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(19,194,194);"
                    >{{ this.sumVendorAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/合作方分润.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">合作方分润：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(250,204,20);"
                    >{{ this.sumpartnerAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>
          </a-row>
        </a-card>

        <a-card style="margin-top:2%;">
          <a-table
            :columns="columns"
            :dataSource="data"
            :pagination="pagination"
            @change="handleTableChange"
            :bordered="true"
            :rowKey="record => record.id"
          >
            <template slot="operation" slot-scope="text,record">
              <div>
                <span class="blue" @click="agentDetail(text,record)">详情</span>
                <a-modal
                  title="工单详情"
                  :visible="visible"
                  :width="1100"
                  @ok="handleOk"
                  @cancel="handleCancel"
                >
                  <a-form>
                    <a-row :gutter="30">
                      <a-col :span="6">
                        <a-form-item
                          label="订单号"
                          :label-col="{ span: 5 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-input
                            placeholder="请输入"
                            v-decorator="[
                              'goodsNameb',
                                {rules: [{ required: true, message: '请输入订单号!' }]}
                                ]"
                          />
                        </a-form-item>
                      </a-col>
                      <a-col :span="6">
                        <a-form-item
                          label="支付号"
                          :label-col="{ span: 5 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-input
                            placeholder="请输入"
                            v-decorator="[
                                'goodsNamed',
                                {rules: [{ required: true, message: '请输入订单号!' }]}
                                ]"
                          />
                        </a-form-item>
                      </a-col>
                      <a-col :span="6">
                        <a-form-item
                          label="支付方式"
                          :label-col="{ span: 6 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-select
                            placeholder="请输入"
                            v-decorator="[
                                'goodsName',
                                {rules: [{ required: true, message: '请输入订单号!' }]}
                                ]"
                          >
                            <a-select-option value="0">全部</a-select-option>
                            <a-select-option value="1">微信支付</a-select-option>
                            <a-select-option value="2">支付宝支付</a-select-option>
                          </a-select>
                        </a-form-item>
                      </a-col>
                      <a-col :span="6" :style="{ textAlign: 'right' }">
                        <a-button type="primary" @click="workorderSearch()">查询</a-button>
                        <a-button type="dashed" @click="workorderExport()">导出</a-button>
                      </a-col>
                    </a-row>
                  </a-form>
                  <!-- table 表格 -->
                  <a-table :columns="apopColumns" :dataSource="apopData" :pagination="false"></a-table>
                  <!-- table表格 -->
                </a-modal>
              </div>
            </template>
          </a-table>
        </a-card>
      </a-tab-pane>

      <a-tab-pane tab="合作方提现" key="2">
        <a-card>
          <a-form :form="form">
            <a-row :gutter="30">
              <a-col :span="8">
                <a-form-item
                  label="工单时间"
                  :label-col="{ span: 6 }"
                  :wrapper-col="{ span: 16,offset:1 }"
                >
                  <a-range-picker
                    style="width: 100%"
                    v-decorator="['rangeConfig', rangeConfig]"
                    show-time
                    format="YYYY-MM-DD HH:mm:ss"
                  />
                </a-form-item>
              </a-col>

              <a-col :span="8">
                <a-form-item
                  label="工单号"
                  :label-col="{ span: 6}"
                  :wrapper-col="{ span: 16, offset: 1}"
                >
                  <a-input
                    placeholder="请输入"
                    v-decorator="[
                    'workNumber',
                   {rules: [{ required: true, message: '请输入工单号!' }]}
                    ]"
                  />
                </a-form-item>
              </a-col>

              <a-col :span="8">
                <a-form-item
                  label="合作方名称"
                  :label-col="{ span: 7}"
                  :wrapper-col="{ span: 16, offset: 1}"
                >
                  <a-input
                    placeholder="请输入"
                    v-decorator="[
                   'agentName',
                   {rules: [{ required: true, message: '请输入代理商名称!' }]}
                  ]"
                  />
                </a-form-item>
              </a-col>
            </a-row>

            <a-row :gutter="30">
              <a-col :span="23" :style="{ textAlign: 'right' }">
                <a-button type="primary" @click="partnerSearch()">查询</a-button>
                <a-button type="dashed" @click="partnerExport()">导出</a-button>
                <a-button @click="resetSearch()">重置</a-button>
              </a-col>
            </a-row>
          </a-form>
        </a-card>

        <a-card style="margin-top:2%;">
          <a-row :gutter="30">
            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/实际入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">合作方分润总额：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >{{ sumSharingAmount }}</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/微信入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">微信收入：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >10000.00</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>

            <a-col :span="8">
              <a-card>
                <a-row :gutter="0">
                  <a-col :span="8">
                    <img src="../../assets/支付宝入账.png" alt>
                  </a-col>
                  <a-col :span="15">
                    <a-row :gutter="40" style="font-size:1rem;">
                      <a-col :span="18">支付宝收入：</a-col>
                      <a-col :span="5">
                        <a-icon type="info-circle"/>
                      </a-col>
                    </a-row>
                    <a-row
                      :gutter="0"
                      style="font-size:1.8rem;margin-top:0.5em;color: rgb(0, 12, 23);"
                    >2945.00</a-row>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>
          </a-row>
        </a-card>
        <!-- 表格模块 -->
        <a-card style="margin-top:2%">
          <a-table
            :columns="columnss"
            :dataSource="dataa"
            :pagination="pagination"
            @change="handleTableChange"
            :bordered="true"
            :rowKey="record => record.code"
          >
            <template slot="operation" slot-scope="text,record">
              <div>
                <span class="blue" @click="partnerDetails(text,record)">详情</span>
                <!-- //弹出层的新建表单 -->
                <a-modal
                  title="合作方详情"
                  :visible="partnervisible"
                  :width="1100"
                  @ok="handleOk"
                  @cancel="handleCancel"
                >
                  <a-form :form="form">
                    <a-row :gutter="30">
                      <a-col :span="6">
                        <a-form-item
                          label="订单号"
                          :label-col="{ span: 6 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-input
                            placeholder="请输入"
                            v-decorator="[
                            'goodsNameb',
                              {rules: [{ required: true, message: '请输入订单号!' }]}
                              ]"
                          />
                        </a-form-item>
                      </a-col>
                      <a-col :span="6">
                        <a-form-item
                          label="支付号"
                          :label-col="{ span: 6 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-input
                            placeholder="请输入"
                            v-decorator="[
                              'goodsNamed',
                              {rules: [{ required: true, message: '请输入订单号!' }]}
                              ]"
                          />
                        </a-form-item>
                      </a-col>
                      <a-col :span="6">
                        <a-form-item
                          label="支付方式"
                          :label-col="{ span: 7 }"
                          :wrapper-col="{ span: 16, offset: 1}"
                        >
                          <a-select
                            placeholder="请输入"
                            v-decorator="[
                              'goodsName',
                              {rules: [{ required: true, message: '请输入订单号!' }]}
                              ]"
                          >
                            <a-select-option value="0">全部</a-select-option>
                            <a-select-option value="1">微信支付</a-select-option>
                            <a-select-option value="2">支付宝支付</a-select-option>
                          </a-select>
                        </a-form-item>
                      </a-col>
                      <a-col :span="6" :style="{ textAlign: 'right' }">
                        <a-button type="primary">查询</a-button>
                        <a-button type="dashed">导出</a-button>
                      </a-col>
                    </a-row>

                    <a-row :gutter="30">
                      <a-col :span="7">
                        <a-form-item
                          label="点位名称"
                          :label-col="{ span: 6}"
                          :wrapper-col="{ span: 15, offset: 1}"
                        >
                          <a-input
                            placeholder="请输入"
                            v-decorator="[
                              'goodsNamee',
                              {rules: [{ required: true, message: '请输入点位号!' }]}
                              ]"
                          />
                        </a-form-item>
                      </a-col>
                    </a-row>
                  </a-form>

                  <a-table :columns="popColumns" :dataSource="popData" :pagination="false"></a-table>
                </a-modal>
              </div>
            </template>
          </a-table>
        </a-card>
        <!-- 表格模块 -->
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script>
const residences = [
  {
    value: "zhejiang",
    label: "Zhejiang",
    children: [
      {
        value: "hangzhou",
        label: "Hangzhou",
        children: [
          {
            value: "xihu",
            label: "West Lake"
          }
        ]
      }
    ]
  },
  {
    value: "jiangsu",
    label: "Jiangsu",
    children: [
      {
        value: "nanjing",
        label: "Nanjing",
        children: [
          {
            value: "zhonghuamen",
            label: "Zhong Hua Men"
          }
        ]
      }
    ]
  }
];
const apopColumns = [
  {
    title: "对账时间",
    dataIndex: "aorderPaymentTimea",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "订单号",
    dataIndex: "orderCode",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "支付号",
    dataIndex: "payTn",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "账单类型",
    dataIndex: "typeName",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "支付方式",
    dataIndex: "forderPaymentTimea",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "订单金额",
    dataIndex: "paidAmount",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "入账金额",
    dataIndex: "inAmount",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "总部分润",
    dataIndex: "vendorSharingAmount",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "合作方润",
    dataIndex: "partnerSharingAmount",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "手续费",
    dataIndex: "charge",
    scopedSlots: { customRender: "phone" },
    align: "center"
  }
];
//弹出层的表单数据
const popColumns = [
  {
    title: "对账时间",
    dataIndex: "orderPaymentTimea",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "订单号",
    dataIndex: "orderPaymentTimeb",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "支付号",
    dataIndex: "orderPaymentTimec",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "合作方名称",
    dataIndex: "orderPaymentTimed",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "点位名称",
    dataIndex: "orderPaymentTimedd",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "分润比例",
    dataIndex: "orderPaymentTimee",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "账单类型",
    dataIndex: "orderPaymentTimef",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "支付方式",
    dataIndex: "orderPaymentTimeg",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "分润金额",
    dataIndex: "orderPaymentTimeh",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "订单金额",
    dataIndex: "orderPaymentTimej",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "手续费",
    dataIndex: "orderPaymentTimek",
    scopedSlots: { customRender: "phone" },
    align: "center"
  }
];
//弹出层的表单数据
const columns = [
  {
    title: "订单支付时间",
    dataIndex: "payTime",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "工单生成时间",
    dataIndex: "createTime",
    scopedSlots: { customRender: "userType" },
    align: "center"
  },
  {
    title: "工单号",
    dataIndex: "code",
    scopedSlots: { customRender: "workOrderNumber" },
    align: "center"
  },
  {
    title: "处理完成时间",
    dataIndex: "processingCompletionTime",
    scopedSlots: { customRender: "processingCompletionTime" },
    align: "center"
  },
  {
    title: "代理商",
    dataIndex: "agentName",
    scopedSlots: { customRender: "agent" },
    align: "center"
  },
  {
    title: "入账金额",
    dataIndex: "inAmount",
    scopedSlots: { customRender: "entryValueSum" },
    align: "center"
  },
  {
    title: "微信金额",
    dataIndex: "wxAmount",
    scopedSlots: { customRender: "wechatAmount" },
    align: "center"
  },
  {
    title: "支付宝金额",
    dataIndex: "alipayAmount",
    scopedSlots: { customRender: "alipayAmount" },
    align: "center"
  },
  {
    title: "总部分润",
    dataIndex: "vendorSharingAmount",
    scopedSlots: { customRender: "headquartersFenRun" },
    align: "center"
  },
  {
    title: "合作方分润",
    dataIndex: "partnerSharingAmount",
    scopedSlots: { customRender: "partnersShareProfits" },
    align: "center"
  },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" },
    align: "center"
  }
];
const columnss = [
  {
    title: "订单支付时间",
    dataIndex: "payTime",
    scopedSlots: { customRender: "phone" },
    align: "center"
  },
  {
    title: "工单生成时间",
    dataIndex: "createTime",
    scopedSlots: { customRender: "userType" },
    align: "center"
  },
  {
    title: "工单号",
    dataIndex: "code",
    scopedSlots: { customRender: "workOrderNumber" },
    align: "center"
  },
  {
    title: "合作方名称",
    dataIndex: "partnerName",
    scopedSlots: { customRender: "processingCompletionTime" },
    align: "center"
  },
  {
    title: "分润金额",
    dataIndex: "sharingAmount",
    scopedSlots: { customRender: "agent" },
    align: "center"
  },
  {
    title: "微信金额",
    dataIndex: "entryValueSum",
    scopedSlots: { customRender: "entryValueSum" },
    align: "center"
  },
  {
    title: "支付宝金额",
    dataIndex: "wechatAmount",
    scopedSlots: { customRender: "wechatAmount" },
    align: "center"
  },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" },
    align: "center"
  }
];
const apopData = [
  {
    key: "1"
  }
];
const popData = [
  {
    key: "1"
  }
];
const dataa = [
  {
    key: "1",
    // orderPaymentTime: "2019/02/09",
    // workOrderGeneratedTime: "2019/02/10 10:51:03",
    // workOrderNumber: "9049766422641879466",
    // processingCompletionTime: "2019/02/10 10:51:03",
    // agent: "代理商",
    // entryValueSum: "12.45",
    // wechatAmount: "6.56",
    // alipayAmount: "5.89",
    // headquartersFenRun: "1.28",
    // partnersShareProfits: "0.56",
    operation: "详情"
  }
];
const data = [
  {
    key: "1",
    orderPaymentTime: "2019/02/09",
    workOrderGeneratedTime: "2019/02/10 10:51:03",
    workOrderNumber: "9049766422641879466",
    processingCompletionTime: "2019/02/10 10:51:03",
    agent: "代理商",
    entryValueSum: "12.45",
    wechatAmount: "6.56",
    alipayAmount: "5.89",
    headquartersFenRun: "1.28",
    partnersShareProfits: "0.56",
    operation: "详情"
  }
];
export default {
  name: "ResidualAdmin",
  data() {
    return {
      form: this.$form.createForm(this),
      rangeConfig: {
        rules: [{ type: "array", required: true, message: "请选择时间!" }]
      },
      data: [],
      //代理商入账总额
      sumAgentAmount: "",
      sumInAmount: "",
      sumVendorAmount: "",
      sumWxAmount: "",
      sumpartnerAmount: "",
      //合作方
      sumSharingAmount: "",

      columns,
      columnss,
      popColumns,
      apopColumns,
      dataa: [],
      popData,
      apopData: [],
      visible: false,
      partnervisible: false,
      pagination: {
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: ["2", "4", "8", "10", "12"],
        showTotal: (total, range) => {
          return `${range[0]}-${range[1]} 共${total}条`;
        },
        pageSize: 2,
        defaultCurrent: 1,
        current: 1,
        total: 5
      },
      visible: false,
      residences
    };
  },
  watch: {},
  computed: {},
  methods: {
    handleSearch(e) {
      e.preventDefault();
      this.form.validateFields((error, values) => {
        console.log("error", error);
        console.log("Received values of form: ", values);
      });
    },
    callback(key) {
      console.log(key);
    },
    handleTableChange(pagination, filters, sorter) {
      const pager = { ...this.pagination };
      pager.current = pagination.current;
      pager.pageSize = pagination.pageSize;
      pager.total = pagination.total;
      this.pagination = pager;
      this.agentSearch();
      // this.findMyBillDetailsPageList();
    },
    showModal() {
      this.visible = true;
    },
    handleOk(e) {
      this.visible = false;
      this.partnervisible = false;
    },
    handleCancel(e) {
      this.visible = false;
      this.partnervisible = false;
    },
    showDetails() {
      this.visible = true;
    },
    partnerDetails() {
      this.partnervisible = true;
      this.partnerDetailsSearch();
    },
    agentDetail(text, record) {
      this.visible = true;
      this.id = record.id;
      console.log(this.id);
      this.workorderSearch();
    },
    //代理商列表初始化
    agentlist() {
      var values = this.form.getFieldsValue();
      this.axios
        .post(this.baseUrl + "/financial/listInit", {
          loginToken: this.$store.state.loginToken
        })
        .then(response => {
          // console.log(response);
          this.pagination.pageSize = response.data.data.pageSize;
        })
        .catch(error => {
          console.log(error);
        });
    },
    //代理商列表查询
    agentSearch() {
      var values = this.form.getFieldsValue();
      if (values.rangeConfig == undefined) {
        values.rangeConfig == undefined;
      } else {
        this.startTime = moment(values.rangeConfig[0]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
        this.endTime = moment(values.rangeConfig[1]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
      }
      this.axios
        .post(this.baseUrl + "/financial/findAgentDailyBillPageList", {
          loginToken: this.$store.state.loginToken,
          endTime: this.endTime,
          startTime: this.startTime,
          pageNum: this.pagination.current,
          pageSize: this.pagination.pageSize,
          code: values.workNumber
        })
        .then(response => {
          console.log(response.data.data.t);
          this.data = response.data.data.t.list;
          this.sumAgentAmount = response.data.data.t.sumAgentAmount;
          this.sumInAmount = response.data.data.t.sumInAmount;
          this.sumVendorAmount = response.data.data.t.sumVendorAmount;
          this.sumWxAmount = response.data.data.t.sumWxAmount;
          this.sumpartnerAmount = response.data.data.t.sumpartnerAmount;
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //代理商列表导出
    agentExport() {
      var values = this.form.getFieldsValue();
      if (values.rangeConfig == undefined) {
        values.rangeConfig == undefined;
      } else {
        this.startTime = moment(values.rangeConfig[0]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
        this.endTime = moment(values.rangeConfig[1]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
      }
      this.axios
        .post(
          this.baseUrl + "/financial/exportDailyBillList",
          {
            loginToken: this.$store.state.loginToken,
            endTime: this.endTime,
            startTime: this.startTime,
            code: values.workNumber
          },
          { responseType: "arraybuffer" }
        )
        .then(response => {
          if (response.status == "200") {
            const aLink = document.createElement("a");
            let blob = new Blob([response.data], {
              type: "application/vnd.ms-excel"
            });
            aLink.href = URL.createObjectURL(blob);
            aLink.download = "代理商工单提现表";
            aLink.click();
            document.body.appendChild(aLink);
          }
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //代理商重置
    resetSearch() {
      this.form.resetFields();
    },
    //代理商工单明细查询

    //代理商工单明细展现
    workorderSearch() {
      var values = this.form.getFieldsValue();
      this.axios
        .post(this.baseUrl + "/financial/findDailyBillDetailsPageList", {
          loginToken: this.$store.state.loginToken,
          dailyBillId: this.id,
          pageNum: this.pagination.current,
          pageSize: this.pagination.pageSize
        })
        .then(response => {
          console.log(response.data.data);
          this.apopData = response.data.data.list;
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //代理商导出
    workorderExport() {
      var values = this.form.getFieldsValue();
      this.axios
        .post(
          this.baseUrl + "/financial/exportDailyBillDetailsList",
          {
            loginToken: this.$store.state.loginToken,
            dailyBillId: this.id
          },
          { responseType: "arraybuffer" }
        )
        .then(response => {
          console.log(response);
          if (response.status == "200") {
            const aLink = document.createElement("a");
            let blob = new Blob([response.data], {
              type: "application/vnd.ms-excel"
            });
            aLink.href = URL.createObjectURL(blob);
            aLink.download = "代理商工单明细详情表";
            aLink.click();
            document.body.appendChild(aLink);
          }
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //合作方提现查询
    partnerSearch() {
      var values = this.form.getFieldsValue();
      if (values.rangeConfig == undefined) {
        values.rangeConfig == undefined;
      } else {
        this.startTime = moment(values.rangeConfig[0]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
        this.endTime = moment(values.rangeConfig[1]._d).format(
          "YYYY-MM-DD HH:mm:ss"
        );
      }
      this.axios
        .post(this.baseUrl + "/partnerFinancial/findPartnerBillPageList", {
          loginToken: this.$store.state.loginToken,
          pageNum: this.pagination.current,
          pageSize: this.pagination.pageSize
        })
        .then(response => {
          console.log(response.data.data);
          this.dataa = response.data.data.t.list;
          this.sumSharingAmount = response.data.data.t.sumSharingAmount;
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //合作方提现导出
    partnerExport() {
      var values = this.form.getFieldsValue();
      this.axios
        .post(
          this.baseUrl + "/partnerFinancial/exportPartnerBillList",
          {
            loginToken: this.$store.state.loginToken
          },
          { responseType: "arraybuffer" }
        )
        .then(response => {
          console.log(response);
          if (response.status == "200") {
            const aLink = document.createElement("a");
            let blob = new Blob([response.data], {
              type: "application/vnd.ms-excel"
            });
            aLink.href = URL.createObjectURL(blob);
            aLink.download = "合作方详情表";
            aLink.click();
            document.body.appendChild(aLink);
          }
        })
        .catch(erro => {
          console.log(erro);
        });
    },
    //合作方详情的查询
    partnerDetailsSearch() {
      var values = this.form.getFieldsValue();
      this.axios
        .post(this.baseUrl + "/partnerFinancial/findPartnerMyBillDetailsLis", {
          loginToken: this.$store.state.loginToken,
          pageNum: this.pagination.current,
          pageSize: this.pagination.pageSize
        })
        .then(response => {
          console.log(response.data.data);
          this.dataa = response.data.data.t.list;
          this.sumSharingAmount = response.data.data.t.sumSharingAmount;
        })
        .catch(erro => {
          console.log(erro);
        });
    }
  },

  created() {
    this.agentlist();
    this.agentSearch();
    this.partnerSearch();
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.ResidualAdmin {
  width: 100%;
}
.ant-btn-primary,
.ant-btn-dashed {
  margin-right: 10px;
}
</style>
